package cn.pconline.autoclub.entity;

import cn.pconline.autoclub.util.EncodeUtils;
import com.alibaba.fastjson.JSONObject;
import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Transient;

/**
 *  车友会等级
 */
@Entity(tableName = "ac_club_level" , logChange = true)
public class ClubLevel {
    
    /**
     * 一星车友会ID
     */
    public static final int LEVEL_ONE = 1;
    /**
     * 二星车友会ID
     */
    public static final int LEVEL_TWO = 2;
    /**
     * 三星车友会ID
     */
    public static final int LEVEL_THREE = 3;
    /**
     * 四星车友会ID
     */
    public static final int LEVEL_FOUR = 4;
    /**
     * 五星车友会ID
     */
    public static final int LEVEL_FIVE = 5;
    
    @Id
    @Column(name = "level_id")
    private long levelId;   //等级ID
    
    @Column(name = "level_name")
    private String levelName;   //等级名称
    
    @Column(name = "level_petrol")
    private int levelPetrol;       //等级条件，满足油值
    
    @Column(name = "level_member")
    private int levelMember;        //等级条件，满足认证会员数
    
    @Transient(cache = false)
    private int nextLevelPetrol;    //下一级的油值
    
    @Transient(cache = false)
    private int nextLevelMember;    //下一级的认证会员数

    public long getLevelId() {
        return levelId;
    }

    public void setLevelId(long levelId) {
        this.levelId = levelId;
    }

    public String getLevelName() {
        return levelName;
    }

    public void setLevelName(String levelName) {
        this.levelName = levelName;
    }

    public int getLevelPetrol() {
        return levelPetrol;
    }

    public void setLevelPetrol(int levelPetrol) {
        this.levelPetrol = levelPetrol;
    }

    public int getLevelMember() {
        return levelMember;
    }

    public void setLevelMember(int levelMember) {
        this.levelMember = levelMember;
    }

    public int getNextLevelPetrol() {
        return nextLevelPetrol;
    }

    public void setNextLevelPetrol(int nextLevelPetrol) {
        this.nextLevelPetrol = nextLevelPetrol;
    }

    public int getNextLevelMember() {
        return nextLevelMember;
    }

    public void setNextLevelMember(int nextLevelMember) {
        this.nextLevelMember = nextLevelMember;
    }
    
    public JSONObject toJson(){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("levelId", getLevelId());
        jsonObject.put("levelName", getLevelName());
        jsonObject.put("levelPetrol", getLevelPetrol());
        jsonObject.put("levelMember", getLevelMember());
        return jsonObject;        
    }    
    
    public JSONObject toJsonEncodeHTML(){
        JSONObject jsonObject = toJson();
        jsonObject.put("levelName", EncodeUtils.encodeForHTMLFilterNull(getLevelName()));      
        return jsonObject;
    }      
}
